package homework.day03;


import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Random;

/**
 * 生成10个0-100的随机数并存入一个List集合中并输出
 * 之后将集合第3到第6个元素翻转并输出
 * 
 * @author Xiloer
 *
 */
public class Test04 {
    public static void main(String[] args) {
        List<Integer> list = new ArrayList<>();
        Random random = new Random();
        for (int i = 0; i < 10; i++) {
            int num = random.nextInt(100);
            list.add(num)	;
        }
        System.out.println("原始列表："+list);

        Integer[] subList = list.subList(2, 6).toArray(new Integer[0]);
        List<Integer> List = Arrays.asList(subList);
        for (int i = 0; i < List.size() / 2; i++) {
            Integer temp = List.get(i);
            List.set(i, List.get(List.size() - 1 - i));
            List.set(List.size() - 1 - i, temp);
        }
        list.subList(2, 6).clear();
        list.addAll(2, List);

        System.out.println("翻转后的列表：" + list);
    }

    }


